<template>
  <div class="count">
    <!-- 组件中使用state数据1 直接去实例上的$store中取值 -->
    <h2>Count组件:{{ $store.state.count }}</h2>
    <h2>Count组件:{{ count1 }}</h2>
    <h2>Count组件:{{ num }}</h2>
    <p>总价格是:{{ $store.getters.totalPrice }}</p>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "Count",
  data() {
    return {};
  },
  mounted() {
    console.log(this.$store, "this.$store");
  },
  computed: {
    ...mapState({ count1: "count", num: "num" }),
  },
};
</script>

<style scoped>
.count {
  background: pink;
}
</style>